package com.luguokong.pet_rescue.controller;

import com.luguokong.pet_rescue.pojo.PetFood;
import com.luguokong.pet_rescue.service.PetFoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/petFood")
public class PetFoodCtrl {
    @Autowired
    private PetFoodService petFoodService;

    @GetMapping("/getByPage")
    public List<PetFood> selectPetFoodAllByPageNumByPageSize(int pageNum, int pageSize){
        List<PetFood> petFoodList = petFoodService.selectPetFoodAllByPageNumByPageSize((pageNum-1)*pageSize, pageSize);
        return petFoodList;
    }

    @GetMapping("/getDataCount")
    public int selectDataCount(){
        int i = petFoodService.selectDataCount();
        return i;
    }

    @PostMapping("/insertPetFood")
    public int insertPetFood(@RequestBody PetFood petFood){
        int i = petFoodService.insertPetFood(petFood);
        return i;
    }

    @GetMapping("/deletePetFoodById")
    public int deletePetFoodById(int foodId){
        int i = petFoodService.deletePetFoodById(foodId);
        return i;
    }

    @PostMapping("/updatePetFoodById")
    public int updatePetFoodById(@RequestBody PetFood petFood){
        int i = petFoodService.updatePetFoodById(petFood);
        return i;
    }


}
